package com.woniu40.petai_user.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniu40.petai_user.entity.Hospital;
import com.woniu40.petai_user.mapper.HospitalMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HospitalService {

    @Autowired
    HospitalMapper hospitalMapper;

    public PageInfo<Hospital> findAll(String name, Integer pageNum, Integer pageSize){
        PageHelper.startPage(pageNum,pageSize);
        List<Hospital> hospitals = hospitalMapper.selectByName(name);
        PageInfo<Hospital> pageInfo = new PageInfo<>(hospitals);
        return pageInfo;
    }

    public Hospital findHospital(Integer hospitalId){
        Hospital hospital = hospitalMapper.selectByPrimaryKey(hospitalId);
        return hospital;
    }
}
